//package com.lu.netty.io.dispatcher
//
//import com.lu.netty.io.client.INettyClientListener
//import com.lu.netty.io.core.NettyConnector
//import com.squareup.moshi.Moshi
//import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
//import java.lang.reflect.ParameterizedType
//import java.lang.reflect.Type
//
///**
// * File Name :JsonMessageDispatcher
// * Author : qihualu
// * Date : 2024/4/19
// * Desc :
// **/
//
//abstract class JsonMessageDispatcher<T> : INettyClientListener {
//    companion object {
//        private const val TAG = "JsonMessageDispatcher"
//    }
//
//    private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
//
//    override fun onMessageArrived(connector: NettyConnector, message: String) {
//        val type = getType()
//        val adapter = moshi.adapter<T>(type)
//        val pojo = adapter.fromJson(message)
//        onReceiveJsonObject(pojo = pojo)
//    }
//
//    private fun getType(): Type {
//        val parameterizedType = this.javaClass.genericSuperclass as ParameterizedType
//        val typeArgs = parameterizedType.actualTypeArguments
//        return typeArgs[0]
//    }
//
//    abstract fun onReceiveJsonObject(pojo: T?)
//
//}